<style>
    .footer-home{display: none}
    #container{position: fixed;height: 100%;width: 100%;  }
    #tip {position: fixed;background-color: #fff;border: 1px solid #ccc;border-radius: 3px;height: 35px; padding: 0 5px;line-height: 35px;  left: 55px;  bottom: 20px;  display: none;  }
    @media screen and (min-width:640px){html{font-size:70px!important;}}
</style>
<link rel="stylesheet" type="text/css" href="resource/css/main.css?v=<?php echo JS_VER; ?>">
<script type="text/javascript"  src="resource/js/rem.js?v=<?php echo JS_VER; ?>"></script>
<!--<header>
    <a href="javascript:history.back();">
        <i class="iconfont icon-xialalan-copy"></i>
    </a>
    <span>附近</span>
</header>-->
<!--地图容器-->
<div id="container"></div>
<div id="tip"></div>
<script type="text/javascript" src="resource/js/jquery.min.js?v=<?php echo JS_VER; ?>"></script>
<script src="//webapi.amap.com/maps?v=1.4.3&key=e5c438490a60083b210b012342ff9339"></script>
<script src="//cache.amap.com/lbs/static/es5.min.js"></script>
<script>
    var map, geolocation;
    //加载地图，调用浏览器定位服务
    map = new AMap.Map('container', {
        resizeEnable: true,
        zoom :13  //缩放级别
    });
    map.plugin('AMap.Geolocation', function() {
        geolocation = new AMap.Geolocation({
            enableHighAccuracy: true, //是否使用高精度定位，默认:true
            timeout: 100000, //超过10秒后停止定位，默认：无穷大
            buttonOffset: new AMap.Pixel(15, 25), //定位按钮与设置的停靠位置的偏移量，默认：Pixel(10, 20)
            zoomToAccuracy: true,
            buttonPosition: 'RB'
        });

//        console.log(ding_wei());

        geolocation.getCurrentPosition();
        map.addControl(geolocation);

//        AMap.event.addListener(map, 'click', getLnglat);
        AMap.event.addListener(geolocation, 'complete', onComplete); //返回定位信息
        AMap.event.addListener(geolocation, 'error', onError); //返回定位出错信息
    });

    function ding_wei() {
        if (AMap.UA.ios) {
            //使用远程定位，见 remogeo.js
            var remoGeo = new RemoGeoLocation();
            //替换方法
            navigator.geolocation.getCurrentPosition = function() {
                return remoGeo.getCurrentPosition.apply(remoGeo, arguments);
            };
            //替换方法
            navigator.geolocation.watchPosition = function() {
                return remoGeo.watchPosition.apply(remoGeo, arguments);
            };
        }
    }

    //获取经纬度
    function onComplete(data) {
        var str = ['定位成功'];
        str.push('经度：' + data.position.getLng()); //经度
        str.push('纬度：' + data.position.getLat()); //纬度

        document.getElementById("my_location").value = data.position.getLng()+","+data.position.getLat(); //我的经纬度
        if(data.accuracy) {
            str.push('精度：' + data.accuracy + ' 米');
        } //如为IP精确定位结果则没有精度信息
        str.push('是否经过偏移：' + (data.isConverted ? '是' : '否'));

        var marker_location = [{
            icon: '<?php echo AST_URL;?>images/location.png',
            position: [data.position.getLng(), data.position.getLat()]
        }];




    }


    //获取地理信息
    function regeocoder_1(lnglatXY) { //逆地理编码
        var geocoder = new AMap.Geocoder({
            radius: 1000,
            extensions: "all"
        });
        geocoder.getAddress(lnglatXY, function(status, result) {
            if(status === 'complete' && result.info === 'OK') {
                geocoder_CallBack_1(result);
            }
        });
    }

    function geocoder_CallBack_1(data) {
        var address = data.regeocode.formattedAddress; //返回地址描述
        //document.getElementById("send-address").value = address;
        //document.getElementById("car_address").innerHTML = address;
    }

    function regeocoder(lnglatXY) { //逆地理编码
        var geocoder = new AMap.Geocoder({
            radius: 1000,
            extensions: "all"
        });
        geocoder.getAddress(lnglatXY, function(status, result) {
            if(status === 'complete' && result.info === 'OK') {
                geocoder_CallBack(result);
            }
        });
    }

    function geocoder_CallBack(data) {
        var address = data.regeocode.formattedAddress; //返回地址描述
        console.log(address);
        //document.getElementById("my-address").value = address
    }
    //解析定位错误信息
    function onError(data) {
        var tip = document.getElementById('tip');
        tip.style.display = 'block';
        tip.innerHTML = '定位失败';
//        document.getElementById('tip').innerHTML = '定位失败';
    }
</script>